package com.lemon.smartsafety.http.service;

import android.content.Context;
import android.util.Log;

import com.lemon.android.http.Field;
import com.lemon.android.http.LemonRequestParams;
import com.lemon.smartsafety.app.Constants;
import com.lemon.smartsafety.app.EventTag;
import com.lemon.smartsafety.app.IApplication;
import com.lemon.smartsafety.app.RefreshType;
import com.lemon.smartsafety.entity.common.CommonVo;
import com.lemon.smartsafety.entity.common.CommonVoEx;
import com.lemon.smartsafety.entity.main.OptionItemVo;
import com.lemon.smartsafety.entity.safe.company.CompanyBuildingBaseCheckItemVo;
import com.lemon.smartsafety.entity.safe.company.CompanyBuildingCheckItemExistVo;
import com.lemon.smartsafety.entity.safe.company.CompanyBuildingCheckItemFlowVo;
import com.lemon.smartsafety.entity.safe.company.CompanyBuildingGroupVo;
import com.lemon.smartsafety.entity.safe.company.CompanyBuildingIndexVo;
import com.lemon.smartsafety.entity.safe.company.CompanyBuildingItemCountVo;
import com.lemon.smartsafety.entity.safe.company.CompanyBuildingVo;
import com.lemon.smartsafety.entity.safe.company.CompanyInfo;
import com.lemon.smartsafety.http.UrlInfo;
import com.lemon.smartsafety.http.callback.HandlerCallback;
import com.lemon.smartsafety.utils.common.AppUtils;
import com.lemon.smartsafety.utils.common.StringUtils;
import com.lemon.smartsafetynew.entity.patrol.SafePatrolCheckItemSetVo;
import com.lemon.smartsafetynew.util.constants.KeyConstants;
import com.orhanobut.logger.Logger;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.ArrayList;
import java.util.List;

import okhttp3.Call;


/**
 * Created by Cooliean on 16/1/19.
 * 数据采集 相关 网络请求服务
 */
public class SafeDataServices extends BaseHttpServices {


    private static final String TAG = "SafeDataServices";


    private SafeDataServices(Context context) {
        super(context);
    }

    public static SafeDataServices init() {
        return new SafeDataServices(IApplication.context());
    }


    /**
     * 获取最近的企业信息
     *
     * @param type
     * @param pageSize
     * @param currentPage
     * @return
     */
    public SafeDataServices getRecentCompanyInfo(RefreshType type, int pageSize, int currentPage) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("page_size", pageSize + "");
        params.put("current_page", currentPage + "");
        return this.getRecentCompanyInfo(type, params);
    }

    /**
     * 获取最近企业信息
     *
     * @param params
     * @return
     */
    public SafeDataServices getRecentCompanyInfo(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<CompanyInfo>> callback = new HandlerCallback<List<CompanyInfo>>(EventTag.TAG_SAFE_DATA_COLLECTION_COMPANY_RECENT) {
        };
        callback.setOther(type);
        if (!AppUtils.isNetworkAvailable(IApplication.context())) {//如果网络不正常,这里就获取本地
            callback.localCallBack(new ArrayList<CompanyInfo>());
            //            callback.localCallBack(getAllLocalCompanyInfo());
            return this;
        }
        callback.setInnerCallBack(new HandlerCallback.InnerCallBack<List<CompanyInfo>>() {
            @Override
            public void onInnerCallBack(List<CompanyInfo> data) {
                //saveCompanyInfo(data);
            }
        });
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_RECENT_LIST);
        OkHttpUtils.get().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }

    /**
     * 获取所有的企业信息
     *
     * @param type
     * @param pageSize
     * @param currentPage
     * @param keyword
     * @return
     */
    public SafeDataServices getAllCompanyInfo(RefreshType type, int pageSize, int currentPage, String keyword) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("page_size", pageSize + "");
        params.put("current_page", currentPage + "");
        params.put("key_word", keyword);
        return this.getAllCompanyInfo(type, params);
    }

    /**
     * 获取公司信息
     *
     * @param params
     * @return
     */
    public SafeDataServices getAllCompanyInfo(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<CompanyInfo>> callback = new HandlerCallback<List<CompanyInfo>>(EventTag.TAG_SAFE_DATA_COLLECTION_COMPANY_LIST) {
        };
        callback.setOther(type);
        if (!AppUtils.isNetworkAvailable(IApplication.context())) {//如果网络不正常,这里就获取本地
            callback.localCallBack(new ArrayList<CompanyInfo>());
            //            callback.localCallBack(getAllLocalCompanyInfo());
            return this;
        }
        callback.setInnerCallBack(new HandlerCallback.InnerCallBack<List<CompanyInfo>>() {
            @Override
            public void onInnerCallBack(List<CompanyInfo> data) {
                //saveCompanyInfo(data);
            }
        });
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_COMPANY_LIST);
        OkHttpUtils.get().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }

    //    /**
    //     * 获取企业信息的本地数据
    //     *
    //     * @return
    //     */
    //    public List<CompanyInfo> getAllLocalCompanyInfo() {
    //        CompanyInfoDao    dao    = AppService.getDBHelper().getDaoSession().getCompanyInfoDao();
    //        List<CompanyInfo> result = dao.queryBuilder().list();
    //        if (result == null) {
    //            return new ArrayList<CompanyInfo>();
    //        }
    //        return result;
    //    }
    //
    //
    //    /**
    //     * 缓存企业信息
    //     *
    //     * @param items
    //     * @return
    //     */
    //    public SafeDataServices saveCompanyInfo(List<CompanyInfo> items) {
    //        CompanyInfoDao dao = AppService.getDBHelper().getDaoSession().getCompanyInfoDao();
    //        try {
    //            if (items != null && !items.isEmpty()) {
    //                dao.insertOrReplaceInTx(items);
    //            }
    //        } catch (Exception e) {
    //            e.printStackTrace();
    //        }
    //        return this;
    //    }


    /**
     * 设置最近企业信息
     *
     * @param companyCode
     * @return
     */
    public SafeDataServices setRecentCompany(String companyCode) {
        String             serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_RECENT_COMPANY_SET);
        LemonRequestParams params    = new LemonRequestParams();
        params.put("company_code", companyCode);
        OkHttpUtils.get().url(serverUrl).params(params).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e) {

            }

            @Override
            public void onResponse(String response) {

            }
        });
        return this;
    }


    /**
     * 获取所有的建筑列表
     *
     * @param type
     * @param pageSize
     * @param currentPage
     * @param keyword
     * @return
     */
    public SafeDataServices getAllBuildingList(RefreshType type, int pageSize, int currentPage, String companyCode,String groupId, String keyword) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("page_size", pageSize + "");
        params.put("current_page", currentPage + "");
        params.put("key_word", StringUtils.nullValue(keyword));
        params.put("company_code", StringUtils.nullValue(companyCode));
        params.put("group_id", StringUtils.nullValue(groupId));
        if (StringUtils.nullValue(groupId).length() != 0) {
            params.put("group_id", StringUtils.nullValue(groupId));
        }
        return this.getAllBuildingList(type, params);
    }

    /**
     * 获取所有的建筑列表
     *
     * @param params
     * @return
     */
    private SafeDataServices getAllBuildingList(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<CompanyBuildingVo>> callback = new HandlerCallback<List<CompanyBuildingVo>>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_LIST);
        Log.v("THE URL IS :",serverUrl);
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 获取建筑场所分类
     *
     * @return
     */
    public SafeDataServices getBuildingTypeList() {
        LemonRequestParams params = new LemonRequestParams();
        return this.getBuildingTypeList(params);
    }

    /**
     * 获取建筑场所分类
     *
     * @param params
     * @return
     */
    private SafeDataServices getBuildingTypeList(LemonRequestParams params) {
        HandlerCallback<List<CommonVoEx>> callback = new HandlerCallback<List<CommonVoEx>>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_TYPE_LIST) {
        };
        callback.setOther(RefreshType.REFRESH);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_TYPE_LIST);
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 保存建筑信息
     *
     * @return
     */
    public SafeDataServices saveBuildingInfoAction(LemonRequestParams params, boolean isEdit) {
        HandlerCallback<CommonVo> callback = new HandlerCallback<CommonVo>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_SAVE) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(isEdit ? UrlInfo.URL_SAFE_DATA_COLLECTION_EDIT_BUILDING_ACTION : UrlInfo.URL_SAFE_DATA_COLLECTION_SAVE_BUILDING_ACTION);
        Logger.i("serverUrl\n"+serverUrl);
        Logger.i("params\n"+params.toString());
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }

    /**
     * 获取建筑场所分类
     *
     * @return
     */
    public SafeDataServices getBuildFloorList(String buildId, String floor_number) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("building_id", StringUtils.nullValue(buildId));
        if (StringUtils.nullValue(floor_number).length() != 0) {
            params.put("floor_number", StringUtils.nullValue(floor_number));
        }
        return getBuildFloorList(params);
    }

    /**
     * 获取建筑场所分类
     *
     * @param params
     * @return
     */
    private SafeDataServices getBuildFloorList(LemonRequestParams params) {
        HandlerCallback<CompanyBuildingIndexVo> callback = new HandlerCallback<CompanyBuildingIndexVo>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_INDEX_INFO) {
        };
        callback.setOther(RefreshType.REFRESH);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_INDEX_INFO);
        Log.i("serverUrl=",serverUrl);
        Log.i("params=",params.toString());
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 建筑方位备注
     *
     * @return
     */
    public SafeDataServices saveBuildingPositionRemark(String title, CompanyBuildingItemCountVo vo) {
        LemonRequestParams params    = new LemonRequestParams("company_building_position_title", "title_id", "");
        String             serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_POSITION_REMARK_ACTION_NEW);
        if (StringUtils.nullValue(vo.getTitleId()).length() != 0) {
            serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_POSITION_REMARK_ACTION_EDIT);
            params.put(LemonRequestParams._txtIdValues, vo.getTitleId());
            params.put("title_id", vo.getTitleId());
        } else {
            params.put(LemonRequestParams._txtIdValues, "");
            params.put("title_id", "");
        }

        params.put("txtBuildingId", vo.getBuildingId(), Field.TYPE_STRING);
        params.put("txtFloorNumber", vo.getFloorNumber(), Field.TYPE_INT);
        params.put("txtPositionMark", vo.getPositionMark(), Field.TYPE_INT);
        params.put("txtPositionTitle", title, Field.TYPE_STRING);
        HandlerCallback<String> callback = new HandlerCallback<String>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_POSITION_REMARK) {
        };
        Logger.e("serverUrl\n"+serverUrl);
        Logger.e("params\n"+params.toString());
        callback.setOther(RefreshType.REFRESH);
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 获取建筑的基础检查项目
     *
     * @return
     */
    public SafeDataServices getBaseCheckItemList(String buildId, String floor_number, String position_remark, String key_word) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("building_id", StringUtils.nullValue(buildId));
        params.put("floor_number", StringUtils.nullValue(floor_number));
        params.put("position_mark", StringUtils.nullValue(position_remark));
        params.put("key_word", StringUtils.nullValue(key_word));
        return getBaseCheckItemList(params);
    }


    /**
     * 建筑的基础检查项目
     *
     * @param params
     * @return
     */
    private SafeDataServices getBaseCheckItemList(LemonRequestParams params) {
        HandlerCallback<List<CompanyBuildingBaseCheckItemVo>> callback = new HandlerCallback<List<CompanyBuildingBaseCheckItemVo>>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_BASE_CHECK_ITEM_LIST) {
        };
        callback.setOther(RefreshType.REFRESH);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_BASE_CHECK_ITEM_LIST);
        Log.i("serverUrl",serverUrl);
        Log.i("params",params.toString());
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 检查周期
     *
     * @return
     */
    public SafeDataServices getCheckCycle() {
        LemonRequestParams params = new LemonRequestParams();

        HandlerCallback<List<OptionItemVo>> callback = new HandlerCallback<List<OptionItemVo>>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_CHECK_CYCLE) {
        };
        callback.setOther(RefreshType.REFRESH);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_CHECK_CYCLE);
       OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 保存检查项目
     *
     * @return
     */
    public SafeDataServices saveCheckItemInfoAction(LemonRequestParams params, boolean isEdit) {
        HandlerCallback<String> callback = new HandlerCallback<String>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_CHECK_ITEM_SAVE_ACTION) {
        };

        String serverUrl = mSharedPreferencesServer.getRequestUrl(isEdit ? UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_CHECK_ITEM_EDIT : UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_CHECK_ITEM_NEW);
        Logger.i(serverUrl);
        Logger.i(params.toString());
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 建筑已有检查项目列表
     *
     * @return
     */
    public SafeDataServices getCheckItemList(String buildId, String floor_number, String position_remark, String key_word) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("building_id", StringUtils.nullValue(buildId));
        params.put("floor_number", StringUtils.nullValue(floor_number));
        params.put("position_mark", StringUtils.nullValue(position_remark));
        params.put("key_word", StringUtils.nullValue(key_word));
        return getCheckItemList(params);
    }


    /**
     * 建筑已有检查项目列表
     *
     * @param params
     * @return
     */
    private SafeDataServices getCheckItemList(LemonRequestParams params) {
        HandlerCallback<CompanyBuildingCheckItemExistVo> callback = new HandlerCallback<CompanyBuildingCheckItemExistVo>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_CHECK_ITEM_LIST) {
        };
        callback.setOther(RefreshType.REFRESH);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_CHECK_ITEM_LIST);
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 建筑已有检查项目列表
     *
     * @return
     */
    public SafeDataServices deleteCheckItem(String itemId) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("item_id", StringUtils.nullValue(itemId));
        HandlerCallback<String> callback = new HandlerCallback<String>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_CHECK_ITEM_DELETE_ACTION) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_CHECK_ITEM_DELETE);
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 检查项目流程List
     *
     * @return
     */
    public SafeDataServices getCheckItemFlowList(String itemId, String key_word) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("item_id", StringUtils.nullValue(itemId));
        if (null != key_word) {
            params.put("key_word", StringUtils.nullValue(key_word));
        }
        HandlerCallback<List<CompanyBuildingCheckItemFlowVo>> callback = new HandlerCallback<List<CompanyBuildingCheckItemFlowVo>>(EventTag.TAG_SAFE_DATA_COLLECTION_BUILDING_CHECK_ITEM_FLOW_LIST) {
        };
        callback.setOther(RefreshType.REFRESH);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_SAFE_DATA_COLLECTION_BUILDING_CHECK_ITEM_FLOW_LIST);
        Logger.i("serverUrl="+serverUrl);
        Logger.json(params.toString());
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 获取单个企业信息
     *
     * @return
     */
    public SafeDataServices getOneCompanyByCode(String companyCode) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("company_code", StringUtils.nullValue(companyCode));
        HandlerCallback<List<CompanyInfo>> callback = new HandlerCallback<List<CompanyInfo>>(EventTag.TAG_ONE_COMPANY) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.COMPANY_GET_ONE);
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 获取单位性质
     */
    public void getUnitPropList() {
        LemonRequestParams params = new LemonRequestParams();
        HandlerCallback<List<OptionItemVo>> callback = new HandlerCallback<List<OptionItemVo>>(EventTag.TAG_UNIT_PROP_SELECT) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.URL_UNIT_PROP_SELECT);
        OkHttpUtils.getInstance().post().tag(callback.getTag()).url(serverUrl).params(params).build().execute(callback);

    }
    /**
     * 获取建筑分组列表
     * @return
     */
    public SafeDataServices getBuildingGroupList() {
        LemonRequestParams params = new LemonRequestParams();
        params.put("page_size", "1000");
        params.put("current_page", "1");
        params.put("key_word", "");
        return this.getBuildingGroupList(RefreshType.REFRESH, params);
    }

    /**
     * 获取建筑分组列表
     *
     * @param type
     * @param pageSize
     * @param currentPage
     * @param keyword
     * @return
     */
    public SafeDataServices getBuildingGroupList(RefreshType type, int pageSize, int currentPage, String keyword) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("page_size", pageSize + "");
        params.put("current_page", currentPage + "");
        params.put("key_word", keyword);
        return this.getBuildingGroupList(type, params);
    }


    /**
     * 获取建筑分组列表
     */
    private SafeDataServices getBuildingGroupList(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<CompanyBuildingGroupVo>> callback =
                new HandlerCallback<List<CompanyBuildingGroupVo>>(EventTag.BUILDING_GROUP_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.BUILDING_GROUP_LIST);
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }


    /**
     * 新建建筑分组
     *
     * @return
     */
    public SafeDataServices newBuildingGroup(String companyCode, String groupName) {
        LemonRequestParams params = new LemonRequestParams("company_building_group", "group_id", "");
        params.put(LemonRequestParams._txtIdValues, "");
        params.put("group_id", "");
        params.put("txtCompanyCode", StringUtils.nullValue(companyCode));
        params.put("txtOrderIndex", "0", Field.TYPE_INT);
        params.put("txtRemark", "", Field.TYPE_STRING);
        params.put("txtGroupName", groupName, Field.TYPE_STRING);
        HandlerCallback<String> callback = new HandlerCallback<String>(EventTag.TAG_BUILDING_GROUP_ACTION) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.BUILDING_GROUP_NEW_ACTION);

        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }

    /**
     * 编辑建筑分组
     *
     * @return
     */
    public SafeDataServices updateBuildingGroup(String companyCode, String groupId, String groupName) {
        LemonRequestParams params = new LemonRequestParams("company_building_group", "group_id", "");
        params.put(LemonRequestParams._txtIdValues, groupId);
        params.put("group_id", groupId);
        params.put("txtCompanyCode", StringUtils.nullValue(companyCode));
        params.put("txtOrderIndex", "0", Field.TYPE_INT);
        params.put("txtRemark", "", Field.TYPE_STRING);
        params.put("txtGroupName", groupName, Field.TYPE_STRING);
        HandlerCallback<String> callback = new HandlerCallback<String>(EventTag.TAG_BUILDING_GROUP_ACTION) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.BUILDING_GROUP_EDIT_ACTION);
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }



    /**
     * 删除建筑分组
     *
     * @return
     */
    public SafeDataServices deleteBuildingGroup(String groupId) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("group_id", groupId);
        HandlerCallback<String> callback = new HandlerCallback<String>(EventTag.TAG_BUILDING_GROUP_DELETE_ACTION) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.BUILDING_GROUP_DELETE_ACTION);
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }

    /**
     * 保存企业绑定信息
     *
     * @return
     */
    public void saveComInfoAction(LemonRequestParams params, boolean isEdit) {
        BindInfoServices.init().saveComInfoAction(params, isEdit);
    }

    //add by Andrew.yin 2017/9/19 begin
    /**
     * 【新】 获取 X楼 X楼层 X方位的检查项列表
     */
    public void getCheckItems(LemonRequestParams params) {
        HandlerCallback<CompanyBuildingCheckItemExistVo> callback = new HandlerCallback<CompanyBuildingCheckItemExistVo>(KeyConstants.URL_GET_BUILDING_FLOOR_POSITION_CHECK_ITEM_LIST) {
        };
        callback.setOther(RefreshType.REFRESH);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_BUILDING_FLOOR_POSITION_CHECK_ITEM_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);
    }

    /**
     * 【新】 绑定标签
     */
    public void bindLabel(LemonRequestParams params) {

        HandlerCallback<String> callback = new HandlerCallback<String>(KeyConstants.URL_BIND_LABEL) {
        };

        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.BIND_LABEL, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);

    }
    //add by Andrew.yin 2017/9/19 end


}
